package com.shipwe.loans.ui.adapter

import android.graphics.Color
import androidx.recyclerview.widget.RecyclerView
import com.shipwe.adapter.ShipweRecyclerViewAdapter
import com.shipwe.adapter.ShipweViewHolderHelper
import com.shipwe.loans.R
import com.shipwe.loans.weight.shadow.CustomShadowLayout
import org.json.JSONObject

/**
 * Shipwe
 * @Author wwdeng
 * @CreateTime: 2024/11/21 10:43
 * @Annotation：流程 - Ocr 适配器
 */
class AuthStepOcrTypeAdapter(recyclerView: RecyclerView?) : ShipweRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.fragment_step_auth_ocr_type_item) {

    override fun setItemChildListener(helper: ShipweViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.ocrItem)
    }

    override fun fillData(helper: ShipweViewHolderHelper, position: Int, model: JSONObject) {
        val ocrItem = helper.getView<CustomShadowLayout>(R.id.ocrItem)
        val ocrTypeImage = helper.getImageView(R.id.ocrTypeImage)
        ocrTypeImage.setImageResource(model.optInt("imgResource"))
        val ocrTypeTitle = helper.getTextView(R.id.ocrTypeTitle)
        ocrTypeTitle.text = model.optString("ocrTitle")
        val ocrTypeSelect = helper.getImageView(R.id.ocrTypeSelect)

        val isSelect = model.optBoolean("isSelect",false)
        when (isSelect){
            true -> {
                ocrItem.setLayoutBackground(Color.parseColor("#FFFFFFFF"))
                ocrTypeTitle.setTextColor(Color.parseColor("#FF000000"))
                ocrTypeSelect.setImageResource(R.drawable.select_theme)
            }
            else -> {
                ocrItem.setLayoutBackground(Color.parseColor("#FFF6F6F6"))
                ocrTypeTitle.setTextColor(Color.parseColor("#FF858381"))
                ocrTypeSelect.setImageResource(R.drawable.page_check_number_normal)
            }
        }
    }
}